package web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Course;
import entity.Student;

public class FindStudentServlet extends HttpServlet {

	@Override
	protected void service(
			HttpServletRequest req, 
			HttpServletResponse res) throws ServletException, IOException {
		
		//模拟查询学生
		Student stu = new Student();
		stu.setName("zhangsan");
		stu.setAge(25);
		stu.setSex("M");
		stu.setInterests(new String[]{"篮球","足球","羽毛球"});
		
		Course c = new Course();
		c.setId(1);
		c.setName("Java");
		c.setDays(85);
		stu.setCourse(c);
		
		//将数据绑定到request
		req.setAttribute("stu",stu);
		//将请求转发给student.jsp
		req.getRequestDispatcher("student.jsp").forward(req, res);
		
		
		
	}

}
